#!/bin/bash

set -e

BuildDir=/Users/zhangqi/src/misc/frame/sketch-compute/sketch-compute/pkg
PkgInstallDir=/Users/zhangqi/src/misc/frame/my-app/lib/sketch-compute
WasmInstallDir=/Users/zhangqi/src/misc/frame/my-app/public

# install the package
rm -rf $PkgInstallDir
mkdir -p $PkgInstallDir
cp -r $BuildDir/* $PkgInstallDir

# install the wasm file
sha256=$(cat $BuildDir/sketch_compute_bg.wasm.sha256)
hash=$(echo $sha256 | cut -c 1-8)
mkdir -p $WasmInstallDir
cp $BuildDir/sketch_compute_bg.wasm $WasmInstallDir/sketch_compute_bg-$hash.wasm
